<%
 /****
  * Folder_Links.jsp
  * This page includes the link definitions that should be added for the
  * folder pages to look properly
  *
  * Copyright 2004 MicroStrategy Incorporated. All rights reserved.
  * version: 1.2
  * xhtml: true
  ****/
%><%@ page errorPage="Error_Links.jsp"
%><%@ page import="com.microstrategy.web.app.utils.JavaScriptBundles"
%><%@ taglib uri="/webUtilTL.tld" prefix="web"
%><%@ page contentType="text/html; charset=UTF-8"
%><%@ page import="com.microstrategy.web.app.beans.PageComponent"
%><%PageComponent mstrPage = (PageComponent)request.getAttribute("mstrPage");%>
<%--
 Display the "links" section of the template as specified in pageConfig.xml (i.e. Admin_Links.jsp)
 <jsp:include page="[a page section]" />
--%>
<jsp:include page='<%=mstrPage.getTemplateInfo().getDefaultTemplate().getSection("links")%>' flush="true" />

<web:ifFeature name="dhtml"><web:then>
<web:clientSideDescriptor IDs = "134,221,3829,3833" />
<web:resource type="javascript" name="serializer.js"/>
<web:resource type="javascript" name="ObjectManipulation.js"/>
<web:resource type="javascript" name="updateManager.js"/>

<web:ifFeature name="check-show-left-toolbar"><web:then>
<web:resource type="javascript" name="mstrTreeViewImpl.js"/>
<web:resource type="javascript" name="mstrFolderTreeViewImpl.js"/>
</web:then></web:ifFeature>
<web:resource type="javascript" name="mstrFolder.js"/>
<web:resource type="javascript" name="mstrInlineRename.js"/>

<!-- Base Mojo CSS file -->
<link rel="stylesheet" type="text/css" href="../javascript/mojo/css/core.css" />
<!-- Mojo Custom Group Editor CSS file -->
<link rel="stylesheet" type="text/css" href="../javascript/mojo/css/cge.css" />
<web:resource type="style" name="mstr/pageFolder.css"/>
<web:ifFeature name="is-portlet"><web:then>
<style>
#folderAllModes {min-width:920px;}
</style>
</web:then></web:ifFeature>


<web:scriptlet> 
var mstrApp = {
    name: '<web:value type="config" name="servletDeploymentName"/>',
    pageName: '<web:beanValue property="name"/>',
    sessionId: '<web:connectionValue property="containerSessionId" />',
    localeId: '<web:connectionValue property="locale"/>',
    thousandsSep: '<web:value type="misc" name="thousandSeparator"/>',
    decimalSep: '<web:value type="misc" name="decimalSeparator"/>',
    listSep: '<web:value type="misc" name="listSeparator"/>',
    units: '<web:value type="misc" name="units"/>',
    unitsLabel: '<web:value type="misc" name="unitsLabel"/>',
      
    taskURL: '<web:taskProcessorName />',    
    objectsBlockCount: '<web:value type="preference" name="objectsBlockCount" />',
    elementsBlockCount: '<web:value type="preference" name="elementsBlockCount" />',
    jsRoot: '../javascript/',   <%-- TODO: Need to send down actual value --%>
    jsMojoRoot: '../javascript/mojo/js/source/',
    mstrDescs : <web:bundleDescriptor name="mojo-cge"/>,    
    onSessionExpired: function() {
        var um = microstrategy.updateManager;
        var action = um.createActionObject(null, mstrUpdateManager.PAGE_REFRESH, microstrategy.servletName + "." + microstrategy.pageName, [], [], [], []);
        um.useIframe = false;
        um.add([action], true);
        um.flushAndSubmitChanges(); 
        return ;
    }
};
</web:scriptlet>

<%!
    // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    // C o n s t a n t s . . .
    // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    
    // This is the URL Parameter that determines we are in "development" mode
    // or not. It is used to define how JavaScript resources are included.
    String URL_PARAM_DEVELOPMENT_MODE = "devmode";
    
    // The name of our Mojo bundle.
    String MOJO_BUNDLE_NAME = "mojo-bootstrap";
    
    // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    // M e t h o d s . . .
    // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    
    // This method simply generates a reference to a JavaScript file
    void includeJavaScriptFile(JspWriter out, String path) throws java.io.IOException {
    	out.println("<script src=\"" + path + "\"></script>");
    }
    
    // This method includes all of the individual (source) JavaScript files in a bundle
    void includeSourceBundleFiles(JspWriter out, String bundleName, String resPrefix) throws java.io.IOException {
    	// Get the Bundle object...
	    JavaScriptBundles.JavaScriptBundle bundle = JavaScriptBundles.getInstance().get(bundleName);
    	
    	// Check for missing bundle...
    	if (bundle == null) {
    		out.println("<!-- Unable to load bundle '" + bundleName + "' -->");
    		return;
    	}

    	// Loop through the files in the bundle...
    	for (int i=0, s = bundle.getFiles().size(); i<s; i++) {
    		// Get the bundle...
    		JavaScriptBundles.JavaScriptFile f = (JavaScriptBundles.JavaScriptFile) bundle.getFiles().get(i);
    		
    		// Generate the inclusion of the file... 
    		includeJavaScriptFile(out, resPrefix + f.getPath() + "/" + f.getFilename());
    	}
    }
    
    // This method includes just the named bundle...
    void includeBundleFile(JspWriter out, String bundleName, String resPrefix) throws java.io.IOException {
    	try {
	    	// Get the relative path to the named bundle...
	    	String bundlePath = JavaScriptBundles.getInstance().getBundlePath(bundleName);
	    	
	    	// Construct the script to include the file...
	    	includeJavaScriptFile(out, resPrefix + bundlePath);
    	}
    	catch (IllegalArgumentException e) {
    		// Error message!
    		out.println("<!-- Unable to resolve path to bundle '" + bundleName + "' -->");
    	}
    }
%>
<%
    // Whether or not we are in "development mode".
    boolean devMode = (request.getParameter(URL_PARAM_DEVELOPMENT_MODE) != null && 
    				   Boolean.valueOf(request.getParameter(URL_PARAM_DEVELOPMENT_MODE)).booleanValue()) || 
    				   false; /* Change this 'false' to 'true' to have it on by default! */
    
%>

<%-- Include the Mojo JavaScript bundle! --%>
<%	if (devMode) {
		// Include all of the individual JavaScript files...
		includeSourceBundleFiles(out, MOJO_BUNDLE_NAME, "");
	} else {
		// Include just the Bundle!
		includeBundleFile(out, MOJO_BUNDLE_NAME, "../");
	}
%>
<%//_ASPTag[
/*
<web:resource type="javascript" name="bundles/mojo-bootstrap.js" />
*/
//_ASPTag]%>

<web:updateManager scope="com.microstrategy.web.app.beans.EnumExecutionScope.REPORT_SCOPE" bean="fb" />
</web:then></web:ifFeature>


